(function () {
    var $self;
    return $self = Ext.define('Aurora.view.AccountDetailsView', {
        extend: 'Ext.Panel',
        xtype: 'accountDetailsView',
        requires: ['Aurora.store.RightsList'],

        config: {
            title: 'Account details',
            items: [{
                xtype: "toolbar",
                docked: "top",
                title: "Edit Note",
                items: [{
                    xtype: "button",
                    ui: "back",
                    text: "Home",
                    action: 'back'
                }, {
                    xtype: "spacer"
                }, {
                    xtype: "button",
                    ui: "action",
                    text: "Save"
                }]
            },{
                xtype: 'formpanel',
                id: 'accountForm',
                height: 160,
                items: [{
                    xtype: 'fieldset',
                    title: 'General',
                    items: [{
                        xtype: 'textfield',
                        name: 'name',
                        label: 'Name'
                    }, {
                        xtype: 'textfield',
                        name: 'emailAddress',
                        label: 'Email'
                    }]
                }]
            }, {
                xtype: 'rightsViewList',
                id: 'rightsView',
                height: 300
            }]
        },

        loadData: function (record) {
            var accountForm = Ext.getCmp('accountForm');
            accountForm.setRecord(record);

            var rview = Ext.getCmp('rightsView');
            var store = rview.getStore();
            if (!store) {
                store = Ext.create('Aurora.store.RightsList');
            }
            var proxy = store.getProxy();

            proxy.setExtraParam('accountId', record.get('accountId'));
            rview.setStore(store);
            store.load();
        }
    });
})();